package utils

import (
	"database/sql"
	"fmt"
)

func GetRows(rows *sql.Rows) (result []map[string]string) {
	columns, err := rows.Columns()
	if err != nil {
		fmt.Println(err)
	}

	values := make([]sql.RawBytes, len(columns))
	scans := make([]interface{}, len(values))

	for i := range values {
		scans[i] = &values[i]
	}

	for rows.Next() {
		_ = rows.Scan(scans...)
		each := make(map[string]string)

		for i, col := range values {
			each[columns[i]] = string(col)
		}

		result = append(result, each)
	}
	return
}
